﻿<script type="text/javascript">
function joinSubmit1() {
	var ff =document.getElementById('commission_f');

	for(var i=0;i<<?=count($list_main_category)?>;i++){
		
		if (document.getElementById('nameVN'+i).value=="" || document.getElementById('nameVN'+i).value==null)
		{
			alert("Fill nameVN "+i);
			document.getElementById('nameVN'+i).focus();
			return;
		}
		
	}
	ff.submit();
}
function joinSubmit() {
	var ff =document.getElementById('commission_f1');

		if (document.getElementById('nameVN').value=="" || document.getElementById('nameVN').value==null)
		{
			alert("Fill nameVN ");
			document.getElementById('nameVN').focus();
			co=1; return;
		}
		
	ff.submit();
	
}

function delCategory(on) {
	location.replace("setting/delcategory?cid="+on);
}

</script>

<div class="content_table_detail">
<table cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse;margin-left: -10px;margin-top: -20px;width: 980px;background: url('images/title_03.gif') repeat-x scroll 0% 0% transparent;" >
				<thead>
					<tr>
						<th style="text-align: left;background: url('images/title_03.gif') repeat-x scroll 0% 0% transparent;height: 24px;">Danh mục chính</th>
						
					</tr>
				</thead>
				</table>
				<br>
			
			<table cellspacing="0" cellpadding="0" border="0" >
				<colgroup>
					<col width="70px">
					<col width="730px">
				</colgroup>
				<tbody>
					
					<tr>
						<th>Danh mục</th>
						<td>
							
							<form id="commission_f" method="POST" action="<?=base_url('setting/edit_main_category')?>" enctype="multipart/form-data" >
							<table >
								<thead>
								<tr>
									
									<th>Vị trí</th>
									<th>Tên danh mục</th>
									<th></th>
									</tr>
								</thead>
								<tbody>
								<?php 
								$i=0;
								foreach ($list_main_category as $value){
									
								?>
									<tr>
									
									<td><input type="text" name="pos[]" id="pos<?=$i?>" value="<?=$value['pos']?>" onkeypress='return event.charCode >= 48 && event.charCode <= 57' style="width: 20px;"></input></td>
									<td>
										<input name="nameVN[]" id="nameVN<?=$i?>" type="text" value="<?=$value['nameVN']?>" style="width: 275px;">
										<input name="id_category[]" id="id_category<?=$i?>" type="hidden" value="<?=$value['id']?>" style="width: 275px;">
									</td>
									<td>
									<img alt="" src="<?=base_url('images/del.png');?>" onclick="hoi=confirm('Bạn có chắc không');if(hoi==true){delCategory('<?=$value['id']?>');}">
									</td>
									
									</tr>
								<?php $i++;
								
								}?>
								<?php if(count($list_main_category)>0){?>
								<tr>
								<td colspan="12"><div class="divBtn" style="width:50px; float:right;" onclick="joinSubmit1();">Cập nhật</div></td>
								</tr>
								<?php }?>
							</tbody>
							</table>
							</form>
							
							
							<form id="commission_f1" method="GET" action="<?=base_url('setting/add_main_category')?>" enctype="multipart/form-data"  >
							<table >
							<tbody>						
									<tr>
									<td>
										<input name="pos" id="pos" type="text" value="0" style="width: 20px;">
									</td>
									<td>
										<input name="nameVN" id="nameVN" type="text" value="" style="width: 275px;">
									</td>
									<td><div class="divBtn" style="width:50px; float:right;" onclick="joinSubmit();">Thêm</div></td>
								</tr>
								</tbody>
							</table>
							
							</form>
							
							
						</td>
					</tr>
					
					
	</table>
			
			</div>